/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef TRI_RECTANGLE_H_
#define TRI_RECTANGLE_H_

#include <iostream>

#include "object.h"
#include "utils.h"

namespace tri
{

class TRectangle : public TObject
{
    friend std::ostream &operator<<( std::ostream&, const TRectangle&);
    
public:
    /**
     * Create a TRectangle 
     * 
     * @param left 
     * @param top 
     * @param right 
     * @param bottom
     */
    TRectangle(float left=0,float top=0, float right=1.0,float bottom=1.0);
    
    /**
     * Create a TRectangle 
     * @param v : {left,top,right,bottom} 
     */
    TRectangle(float v[4]);
    
    virtual ~TRectangle();
    
    /**
     * Get the contained value
     * 
     * @param v : storage for {left,top,right,bottom} 
     */
    void get(float v[4]);
	
	/**
	 * Set the TRectangle value
	 */
	void setValue(float left=0,float top=0, float right=1.0,float bottom=1.0);
	
	/**
	 * Set the TRectangle value
	 */
	void setValue(TRectangle* r);
    
    /**
     * Get an editable refrence to the internal values 
     */
    const float* getValue();
    
    /**
     * Get the corner value of the TRectangle
     * 
     * @param v : values are stored {left,top,right,top,left,bottom,right,bottom}
     */
    void getRectValue(float v[8]);
    
    /**
     * Move the TRectangle x and y units
     */
    void translate(float x,float y);
    
    /**
     * Get an editable copy of this TRectangle
     */
    TRectangle copy();
	
	/**
	 * Get Top value 
	 */
	float getTop();
	
	/**
	 * Set Top Value
	 */
	void setTop(float f);
	
	/**
	 * Get Left value 
	 */
	float getLeft();
	
	/**
	 * Set Left Value
	 */
	void setLeft(float f);
	
	/**
	 * Get Right value 
	 */
	float getRight();
	
	/**
	 * Set Right Value
	 */
	void setRight(float f);
	
	/**
	 * Get Bottom value 
	 */
	float getBottom();
	
	/**
	 * Set Bottom Value
	 */
	void setBottom(float f);
    
	/**
	 * Get object string value
	 */
	std::string toString() const;
	
    float value[4];
};



}

#endif /*RECTANGLE_H_*/
